﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RBS.Common;
using RBS.Web.Hotel.Models.Order;

namespace RBS.Web.Hotel.Areas.Settlement.Controllers
{
    public class PrintController : Controller
    {
        //
        // GET: /Settlement/Print/

        public ActionResult OrderPint(int orderid)
        {
            var model = new OrderViewModel(); 
            model.OrderModel = new RBS.Core.BLL.D_Order().GetModel(orderid);
            model.OrderDetailsModel = new RBS.Core.BLL.V_OrderDetails().GetModelList("OrderId=" + orderid);
            model.OrderModel.OrderAmount = model.OrderDetailsModel.Sum(c => c.Num * c.DisAmount*c.Weight);
            if (model.OrderModel.U_Id != RBSKeys.Visitor)
                model.User = new RBS.Core.BLL.U_User().GetModelByCache(model.OrderModel.U_Id);
            else
            {
                var user = new RBS.Core.Model.U_User
                    {
                        U_Name = "到店食客",
                        Id = -1
                    };
                model.User = user;
            }  

            model.SeateName = new RBS.Core.BLL.Hotel.H_Hotel_Seat().GetModelByCache(Convert.ToInt32(model.OrderModel.DineTable)).Name; 

            model.Seetlement = new RBS.Core.BLL.D_Settlement().GetModelList("OrderId=" + orderid).FirstOrDefault(); 
            if (model.Seetlement == null)
            {
                return Content("当前订单还没结账！");
            }
            return View(model);
        }

    }
}
